package com.kaishengit.dao;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.kaishengit.pojo.User;

@Repository
public class UserDao extends BaseDao<User, String> {

	public User findNameAndPassword(User user) {
		String hql = "from User where username = ? and password = ?";
		System.out.println("+++++" + getSession());

		Query query = getSession().createQuery(hql);
		query.setParameter(0, user.getUsername());
		query.setParameter(1, user.getPassword());
		return (User) query.uniqueResult();
	}

	public User findByName(String username) {
		String hql = "from User where username = :username";
		Query query = getSession().createQuery(hql);
		query.setParameter("username", username);
		return (User) query.uniqueResult();
	}

}
